//设备相关接口的管理
import $http from '@/service/request.js'



//获取在售商品信息
//接口:/shopping/allshopequip
//GET
export const _allshopequip = () =>{
	return $http.request({
		url:'/shopping/allshopequip',
		method:'GET',
		header:{
			"Content-Type":"application/json"
		}
	})
}

//根据类型获取在售商品信息
//接口:/shopping/typeshopequip
//POST
export const _typeshopequip = ({type}) =>{
	return $http.request({
		url:'/shopping/typeshopequip',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			type
		}
	})
}

//根据用户账号获取购买记录
//接口:/shopping/accountrecords
//POST
export const _accountrecords = ({account_user}) =>{
	return $http.request({
		url:'/shopping/accountrecords',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user
		}
	})
}

//用户购买商品
//接口:/shopping/usershop
//POST
export const _usershop = ({account_user,serialnum_commodity,number_shopping}) =>{
	return $http.request({
		url:'/shopping/usershop',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user,
			serialnum_commodity,
			number_shopping
		}
	})
}


//新品展示
//接口：/shopping/dateshopequip
//GET
export const _newshow = () =>{
	return $http.request({
		url:'/shopping/dateshopequip',
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
	})
}

//增加地址
//接口：/shopping/addaddress
//方式：POST
export const _addaddress = ({account_user,account_address,username_address,pro_city,addressdetail,isdefault}) =>{
	return $http.request({
		url:'/shopping/addaddress',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user,
			account_address,
			username_address,
			pro_city,
			addressdetail,
			isdefault
		}
	})
}

//根据商品名称模糊搜索查询商品
//接口:/shopping/nameshopequip
//POST
export const _nameshopequip = ({name_commodity}) =>{
	return $http.request({
		url:'/shopping/nameshopequip',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			name_commodity
		}
	})
}


//查找地址
//接口:/shopping/selectaddress
//POST
export const _selectaddress = ({account_user}) =>{
	return $http.request({
		url:'/shopping/selectaddress',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user
		}
	})
}


//查找地址
//接口:/shopping/deleteaddress
//DELETE
export const _deleteaddress = ({account_user,account_address,username_address,pro_city,addressdetail}) =>{
	return $http.request({
		url:'/shopping/deleteaddress',
		method:'DELETE',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user,
			account_address,
			username_address,
			pro_city,
			addressdetail
		}
	})
}

//查找地址
//接口:/shopping/updateaddress
//POST
export const _updateaddress = ({id,account_address,pro_city,addressdetail,isdefault,username_address}) =>{
	return $http.request({
		url:'/shopping/updateaddress',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			id,
			account_address,
			pro_city,
			addressdetail,
			isdefault,
			username_address
		}
	})
}
//根据加入方式从购物车或者收藏里查询单个
//接口:/shopping/findProduct
//POST
export const _findProduct = ({account_user,joining_method}) =>{
	return $http.request({
		url:'/shopping/findProduct',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user,
			joining_method
		}
	})
}
//根据加入方法将商品加入到收藏或者购物车
//POST
//接口:/shopping/addProduct

export const _addProduct = ({serialnum_commodity,account_user,joining_method,joining_number}) =>{
	return $http.request({
		url:'/shopping/addProduct',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			serialnum_commodity,
			account_user,
			joining_method,
			joining_number
		}
	})
}
//根据加入方法将商品从收藏或者购物车删除
//DELETE
//接口:/shopping/deleteByProduct
export const _deleteByProduct = ({account_user,serialnum_commodity,joining_method}) =>{
	return $http.request({
		url:'/shopping/deleteByProduct',
		method:'DELETE',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user,
			serialnum_commodity,
			joining_method
		}
	})
}
//查询商品信息
//GET
//接口:/shopping/findCommodity
export const _findCommodity = (serialnum) =>{
	return $http.request({
		url:'/shopping/findCommodity?serialnum_commodity='+serialnum,
		method:'GET',
		header:{
			"Content-Type":"application/json"
		}
	})
}
// 根据商品序列号查询评论
//POST
//接口:/shopping/getcommentsbyserialnum

export const _getcommentsbyserialnum = ({serialnum_commodity}) =>{
	return $http.request({
		url:'/shopping/getcommentsbyserialnum',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			serialnum_commodity
		}
	})
}